﻿namespace Example
{
    using System;

    using OpenQA.Selenium;
    using OpenQA.Selenium.Chrome;
    using OpenQA.Selenium.Firefox;
    using OpenQA.Selenium.IE;

    using Xunit;

    public sealed class AlanDeanFacts
    {
        [Fact(Skip = "OpenQA.Selenium.WebDriverException : No response from server for url http://localhost:18754/session")]
        public void chrome()
        {
            IWebDriver driver = null;
            try
            {
                driver = new ChromeDriver();
                test(driver);
            }
            finally
            {
                if (null != driver)
                {
                    driver.Quit();
                }
            }
        }

        [Fact]
        public void firefox()
        {
            IWebDriver driver = null;
            try
            {
                driver = new FirefoxDriver();
                test(driver);
            }
            finally
            {
                if (null != driver)
                {
                    driver.Quit();
                }
            }
        }

        [Fact(Skip = "OpenQA.Selenium.WebDriverException : No response from server for url http://localhost:3219/session")]
        public void internet_explorer()
        {
            IWebDriver driver = null;
            try
            {
                driver = new InternetExplorerDriver();
                test(driver);
            }
            finally
            {
                if (null != driver)
                {
                    driver.Quit();
                }
            }
        }

        private static void test(IWebDriver driver)
        {
            var navigation = driver.Navigate();
            navigation.GoToUrl(new Uri("http://www.alan-dean.com/"));

            Assert.Equal("Alan Dean", driver.Title);
        }
    }
}